package com.rtos.model.process.queue;

import com.rtos.model.process.Process;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

/**
 * @Author: biubiu0002
 * @Date: 2021-10-16 14:21
 **/
public class RunningQueue {

    private volatile static ObservableList<Process> runningQueue = FXCollections.observableArrayList();

    public static ObservableList<Process> getList() {
        return runningQueue;
    }

    public static Process getFirst() {
        if(runningQueue.size()>0){
            return runningQueue.get(0);
        }
        return null;

    }

    public static boolean isEmpty() {
        return runningQueue.isEmpty();
    }

    public synchronized static void remove() {
        runningQueue.remove(0);

    }

    public synchronized static void add(Process process) {
        if (runningQueue.size() > 1) {
            return;
        }
        runningQueue.add(process);

    }

}
